//
//  creatRDVController.m
//  spotrs
//
//  Created by xu on 16/5/10.
//  Copyright © 2016年 TZ. All rights reserved.
//

#import "creatRDVController.h"
#import "orderViewController.h"
@implementation creatRDVController
static  creatRDVController* _instance = nil;
+(creatRDVController*)sharedInstance
{
    @synchronized(self) {
        if(_instance==nil) {
            _instance = [[creatRDVController alloc] init];
        }
    }
    
    return _instance;
}

-(RDVTabBarController*)creatRDV
{
    UIViewController *firstViewController = [[mainViewController alloc] init];
//    UINavigationController *firstNavigationController = [[UINavigationController alloc]
//                                                   initWithRootViewController:firstViewController];
//    [firstNavigationController.navigationBar setHidden:YES];
    
    UIViewController *secondViewController = [[sportViewController alloc] init];
//    UINavigationController *secondNavigationController = [[UINavigationController alloc]
//                                                    initWithRootViewController:secondViewController];
    
    UIViewController *thirdViewController = [[messageViewController alloc] init];
//    UINavigationController *thirdNavigationController = [[UINavigationController alloc]
//                                                   initWithRootViewController:thirdViewController];
    
    UIViewController *fourViewController = [[friendViewController alloc] init];
//    UINavigationController *fourNavigationController = [[UINavigationController alloc]
//                                                  initWithRootViewController:fourViewController];
    UIViewController *fiveViewController = [[myViewController alloc] init];
    RDVTabBarController *rdv = [[RDVTabBarController alloc] init];
    [rdv setViewControllers:@[firstViewController,
                                                secondViewController,
                                                thirdViewController,
                                                fourViewController,fiveViewController]];
    [rdv.tabBar setHeight:toolbarHright];
    
    [self customizeTabBarForController:rdv];
     
    return rdv;
}
- (void)customizeTabBarForController:(RDVTabBarController *)tabBarController
{
    UIImage *finishedImage = [UIImage imageNamed:@"tabbar_normal_background"];
    UIImage *unfinishedImage = [UIImage imageNamed:@"tabbar_normal_background"];
    NSArray *tabBarItemImages = @[@"11", @"22", @"33", @"44",@"44"];
    NSArray *nameArr = @[@"首页",@"运动圈",@"消息",@"打赏",@"我"];
    NSInteger index = 0;
    for (RDVTabBarItem *item in [[tabBarController tabBar] items]) {
        [item setBackgroundSelectedImage:finishedImage withUnselectedImage:unfinishedImage];
        UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",
                                                      [tabBarItemImages objectAtIndex:index]]];
        UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@",
                                                        [tabBarItemImages objectAtIndex:index]]];
        [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage];
        item.title = [NSString stringWithFormat:@"%@",[nameArr objectAtIndex:index]];
        index++;
    }
}
@end
